package com.cis.web.controller.education;

import java.util.List;

import com.cis.common.annotation.Log;
import com.cis.common.core.controller.BaseController;
import com.cis.common.core.domain.AjaxResult;
import com.cis.common.core.page.TableDataInfo;
import com.cis.common.enums.BusinessType;
import com.cis.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cis.education.domain.EduFingerPrint;
import com.cis.education.service.IEduFingerPrintService;

/**
 * 指纹管理Controller
 * 
 * @author admin
 * @date 2022-03-24
 */
@Controller
@RequestMapping("/education/fingerprint")
public class EduFingerPrintController extends BaseController
{
    private String prefix = "education/fingerprint";

    @Autowired
    private IEduFingerPrintService eduFingerPrintService;

    @RequiresPermissions("education:fingerprint:view")
    @GetMapping()
    public String Fingerprint()
    {
        return prefix + "/fingerprint";
    }

    /**
     * 查询指纹管理列表
     */
    @RequiresPermissions("education:fingerprint:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(EduFingerPrint eduFingerPrint)
    {
        startPage();
        List<EduFingerPrint> list = eduFingerPrintService.selectEduFingerPrintList(eduFingerPrint);
        return getDataTable(list);
    }

    /**
     * 导出指纹管理列表
     */
    @RequiresPermissions("education:fingerprint:export")
    @Log(title = "指纹管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(EduFingerPrint eduFingerPrint)
    {
        List<EduFingerPrint> list = eduFingerPrintService.selectEduFingerPrintList(eduFingerPrint);
        ExcelUtil<EduFingerPrint> util = new ExcelUtil<EduFingerPrint>(EduFingerPrint.class);
        return util.exportExcel(list, "指纹管理数据");
    }

    /**
     * 新增指纹管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存指纹管理
     */
    @RequiresPermissions("education:fingerprint:add")
    @Log(title = "指纹管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(EduFingerPrint eduFingerPrint)
    {
        return toAjax(eduFingerPrintService.insertEduFingerPrint(eduFingerPrint));
    }

    /**
     * 修改指纹管理
     */
    @RequiresPermissions("education:fingerprint:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        EduFingerPrint eduFingerPrint = eduFingerPrintService.selectEduFingerPrintById(id);
        mmap.put("eduFingerPrint", eduFingerPrint);
        return prefix + "/edit";
    }

    /**
     * 修改保存指纹管理
     */
    @RequiresPermissions("education:fingerprint:edit")
    @Log(title = "指纹管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(EduFingerPrint eduFingerPrint)
    {
        return toAjax(eduFingerPrintService.updateEduFingerPrint(eduFingerPrint));
    }

    /**
     * 删除指纹管理
     */
    @RequiresPermissions("education:fingerprint:remove")
    @Log(title = "指纹管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(eduFingerPrintService.deleteEduFingerPrintByIds(ids));
    }
}
